<?php
namespace app\admin\controller;


use think\facade\Db;
use think\facade\Request;
use think\facade\View;

class Order
{
    public function orderList()
    {
        $status=Db::name('order_status')->select();
        View::assign('status',$status);
        $keywords=Request::post('keywords');
        $post = Request::post();
        $where=[];
        if(isset($keywords) && $keywords <> '')                     $where[] = ['order_sn','like',"%{$keywords}%"];
        if (isset($post['status_id']))  $where[] = ['status','in',$post['status_id']];
        if(isset($post['k_time']) && !empty($post['k_time'])) $where[] = ['addtime','> TIME',$post['k_time']];
        if(isset($post['j_time']) && !empty($post['j_time'])) $where[] = ['addtime','< TIME',$post['j_time']];
        if(isset($post['price1']) && $post['price1']<>'') $where[] = ['price','>=',$post['price1']];
        if(isset($post['price2']) && !empty($post['price2'])) $where[] = ['price','<=',$post['price2']];
        View::assign($post);
        $order=Db::name('order')->alias('o')->join('order_status s','o.status=s.status_id','left')->where($where)->select();
        View::assign('order',$order);
        return View::fetch();
    }
}